num = [[1,3],[2,6],[8,10],[15,18]]
ans = []
fl = 0
for i in range(len(num) - 1):
    if fl:
        fl -= 1
        continue
    if num[i][1] >= num[i + 1][0] or num[i][1] >= num[i + 1][1]:
        a = min(num[i][0], num[i + 1][0])
        b = max(num[i + 1][1], num[i + 1][1])
        ans.append([a, b])
        fl = 1
    else:
        ans.append(num[i])
if fl == 0:
    ans.append(num[-1])